<!DOCTYPE html>
<html>
	<head>
		<title>派单中心</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport"
			content="width=device-width,initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<meta name="format-detection" content="telephone=no" />
		<meta name="format-detection" content="email=no" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<!--删除默认的苹果工具栏和菜单栏。-->
		<link rel="stylesheet" href="plug-in/ydui/css/ydui.css?rev=@@hash"/>
		<link rel="stylesheet" href="plug-in/ydui/css/demo.css"/>
		<link rel="stylesheet" href="plug-in/Validform/css/style.css"/>
		<script src="plug-in/ydui/js/ydui.flexible.js"></script>
		<style type="text/css">
			.demo-pagetitle{
				position:relative;
				top:10%;
			}
	    	.m-grids-4{
	    		top:20%;
	    		background:transparent;
	    	}
	    	
			.m-grids-4 .grids-item {
				width: 50%;
			}
			.demo-icons [class^="icon-"]:before, .demo-icons [class*=" icon-"]:before { font-size: 0.6rem; color: #FF685D; }
    	</style>
		<link rel="stylesheet" href="webpage/css/login-main.css" />
		<link rel="stylesheet" href="webpage/css/faultfeedback.min.css" />
		<script src="webpage/jQuery/jquery-2.1.4.js"></script>
	</head>
	<body>
		<!-- <div class="div"></div> -->
		<section class="g-flexview">
			<form id="form" name="form" class="registerform" method="post">
			<header class="m-navbar">
	        	<a class="navbar-item" href="javascript:history.go(-1)"><i class="back-ico"></i></a>
	        	<div class="navbar-center"><span class="navbar-title">派单中心</span></div>
	        	<input id="js_submit" class="navbar-right" type="submit" value="提交" />
	    	</header>
		    <section class="g-scrollview">
		        <div id="table" class="m-cell demo-small-pitch">
		        	<div class="cell-item" style="display: none">
		                <div class="cell-left">id:</div>
		                <div class="cell-right"><input id="id" name="id" type="text" class="cell-input" placeholder="" autocomplete="off" /></div>
		            </div>
		            <div class='cell-item'> 
						<div class='cell-left'>工单号：</div> 
					  	<label class='cell-right cell-arrow'>
							<input id='infoWordOrder' name='infoWordOrder' class='cell-select' dataType="*" />
						</label>
					</div>
					<div class='cell-item'> 
						<div class='cell-left'>派发部门：</div> 
					  	<label class='cell-right cell-arrow'>
							<select id='infoForDepart' name='infoForDepart' class='cell-select'></select>
						</label>
					</div>
					<div class='cell-item'> 
						<div class='cell-left'>派发人员：</div> 
					  	<label class='cell-right cell-arrow'>
							<input id='infoCreateName' name='infoCreateName' class='cell-select' readOnly="true"/>
						</label>
					</div>
					<div class='cell-item'> 
						<div class='cell-left'>故障类型：</div> 
					  	<label class='cell-right cell-arrow'>
							<select id='infoMelfunctionType' name='infoMelfunctionType' class='cell-select'></select>
						</label>
					</div>
					<div class='cell-item'> 
						<div class='cell-left'>故障位置选择：</div> 
					  	<label class='cell-right cell-arrow'>
							<input id='infoPlace' name='infoPlace' class='cell-select' />
						</label>
					</div>
		        </div>
			</section>
			</form>
		</section>
	</body>
	<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
	<script src="webpage/js/ydui.city.js"></script>
	<script src="plug-in/ydui/js/ydui.js"></script>
	<script src="http://malsup.github.io/jquery.form.js"></script>
	<script type="text/javascript" src="plug-in/Validform/js/Validform_v5.3.1_min_zh-cn.js"></script>
	<script type="text/javascript" src="plug-in/Validform/js/initValidform.js"></script>
	<script type="text/javascript">
	$(function(){
		/**权限验证*/
		$(function(){
			volidRole("管理员");
		});
	})	
	$(function(){
			$.ajax({//添加内容（单位、类型，时间和人员）
				cache:false,
				type: 'post', // 提交方式 get/post
				async:false,
		   		url: "infomelController.do?adminDoInfo", // 需要提交的 url
		   		dataType:"json",
		       	success: function(json){ // data 保存提交后返回的数据，一般为 json 数据
		       		var infoForDepart = $("#infoForDepart");//派发单位
		       		//var infoCreateDate = $("#infoCreateDate") ;//派发时间
		       		var infoCreateName = $("#infoCreateName");//派发人员
		       		var infoMelfunctionType = $("#infoMelfunctionType");//故障类型
		       		if(json.success){
		       			var entity = json.obj;
			       		//派发时间确定
			       		//infoCreateDate.attr("type","date");
			       		//var date =   new Date(yyyy,mth,dd,hh,mm,ss);
		       			//infoCreateDate.attr("value",date);//getMyDate(entity.infoCreateDate));
						//派发人员
						infoCreateName.attr("value",entity.infoCreateName.userKey);
			       		//下派单位
						$.each(entity.infoForDepart,function(i,item){
			       			var html = option_right(item.id,item.comRegionName+" "+item.comPlaceName);
			       			infoForDepart.append(html);
			       		});
			       		//故障类型
						$.each(entity.infoMelfunctionType,function(i,item){
			       			var html = option_right(item.id,item.dicMelname);
			       			infoMelfunctionType.append(html);
			       		});
		       		}
		       	},
		       	error : function(){
		       		
		       	}
			})
			return false;
		})
		$('#js_submit').on('click', function(){
			if(!StopSubmit()){
				return false;
			}
			var check=confirm("您确定要提交表单吗？");
			if(!check){
				return false;
			}
			$('#form').on('submit', function(){
				$.ajax({
					cache:false,
					type: 'post', // 提交方式 get/post
					async:false,
			   		url: "infomelController.do?doAdd", // 需要提交的 url
			  		data:$('form').serialize(),
			   		dataType:"json",
			       	success: function(json){ // data 保存提交后返回的数据，一般为 json 数据
			       		if(json.success){
			       			alert("提交成功");
			        		window.location.href="loginController.do?login";
			        		return false;
			       		}else{
			       			alert("提交失败，请重新提交！");
			       		}
		        		return false;
			       	},
			       	error:function(){
			       		alert("您的网络可能出现问题，请重试！");
			       	}
				})
				return false;
			})
		})
	    
	    function getMyDate(str){  
            var oDate = new Date(str),  
            oYear = oDate.getFullYear(),  
            oMonth = oDate.getMonth()+1,  
            oDay = oDate.getDate(),  
            oHour = oDate.getHours(),  
            oMin = oDate.getMinutes(),  
            oSen = oDate.getSeconds(),  
            oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay) +' '+ getzf(oHour) +':'+ getzf(oMin) +':'+getzf(oSen);//最后拼接时间  
            return oTime;  
        };  
        //补0操作  
        function getzf(num){  
            if(parseInt(num) < 10){  
                num = '0'+num;  
            }  
            return num;  
        }
        function option_right(id,name){
        	var top =  " <option value=' " ;
        	var body = " '>" ;
        	var foot = "</option> " ;
        	var http = top+id+body+name+foot;
        	return http;
        }
        function volidRole(role){
			$.ajax({
				cache: false,
				type: 'post', // 提交方式 get/post
				async:false,
		   		url: "volidformController.do?volidRole", // 需要提交的 url
		   		dataType:"json",
		   		data:{"s_role":role},
		       	success: function(json){
		       		if(json.success){
		       			return true;
		       		}else{
		       			alert("您没有权限！如需获取权限，请联系管理员！");
		       			window.location.href="loginController.do?login";
		       		}
					return false;
		       	},
		       	error : function(){
		       		alert("您的网络可能出现了问题，请重试！");
		       	}
			})
			return false;
		};
	</script>
</html>